package custom.MetaObjectTest;

import custom.MetaObjectTest.po.Order;
import custom.MetaObjectTest.po.User;
import org.apache.ibatis.reflection.MetaObject;
import org.apache.ibatis.reflection.SystemMetaObject;

import java.util.ArrayList;
import java.util.List;

public class TestMetaObject {
	private static User user ;
	static {
		List<Order> orders = new ArrayList<Order>(){
			{
				add(new Order("202005290857","《失乐园》"));
				add(new Order("202005290859","《白夜行》"));
			}
		};
		 user = new User("张三",22,orders);
	}
	public static void main(String[] args) {
		testA();
	}

	public static void testA(){

		MetaObject metaObject = SystemMetaObject.forObject(user);
		// 获取第一笔订单的商品名称
		System.out.println(metaObject.getValue("orders[0].goodsName"));

	}
}
